﻿using PersonBlog.Model;
using PersonBlog.BLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PersonBlog.Models;
using System.Data;
using PersonBlog.Common;
using System.Net;
using System.IO;

namespace PersonBlog.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }


        WeatherCityBLL wcBll = new WeatherCityBLL();
        WeatherInfoBLL wiBll = new WeatherInfoBLL();
        AgendaManageBLL amBll = new AgendaManageBLL();
        TaskManageBLL taskBll = new TaskManageBLL();

        public ActionResult Main()
        {
            DataSet ds = wiBll.GetNewList();
            List<WeatherInfoEntity> weatherInfoList = Assistant.DataSetToEntityList<WeatherInfoEntity>(ds, 0).ToList();
            ViewBag.WeatherInfo = weatherInfoList.FirstOrDefault(s=>s.CityName=="贵阳");

            DataSet amDs = amBll.GetTop4List();
            List<AgendaManageEntity> agendaList = Assistant.DataSetToEntityList<AgendaManageEntity>(amDs, 0).ToList();
            ViewBag.AgendaList = agendaList;

            DataSet taskDs = taskBll.GetTop5List();
            List<TaskManageModel> taskList = new List<TaskManageModel>();
            if (taskDs.Tables[0].Rows.Count>0)
            {
                taskList = Assistant.DataSetToEntityList<TaskManageModel>(taskDs, 0).ToList();
            }
            ViewBag.TaskList = taskList;
            
            return View();
        }

        
    }
}